var query = require("../config/conn.js");
var token = require("./token");


class User {
     constructor(username,password,api_token){
         this.username = username;
         this.password = password;
         this.api_token = api_token;
     }	  
     async finduser(username,password){
          var _sql = "select id, wx_img,nickname,userimg,gender,email,profession,age,instroduction,isadmin from blogger where username = ? and password = ?";
          var params = [username,password]
          return new Promise(function(resolve,reject){
          		 query(_sql,params,function(err,result){    
		          	 if(err){
		          	 	resolve([]);
		          	 }
      					else{
      						resolve(result[0]);
      					}
		          })
          })
         
     }
}



module.exports = User;